let listLoad = require('../../common/mixinList');
Page({
    behaviors: [listLoad],
    data: {
        statistics: null, //统计信息
        reqUrl: '/supplier/supplier/log?type=2&from=money',
        withdrawalLoading: false, //提现按钮loading
        openChoose: false,
        // actions: [{
        //         name: '提现到微信',
        //         index: 0,
        //     },
        //     {
        //         name: '提现到银行卡',
        //         index: 1,
        //     },
        // ],
        enableNum: null, //允许提现的金额
    },
    onLoad: function(options) {
        this.getList(true)
    },
    onShow() {
        this.getStatistics()
    },
    /**获取统计信息 */
    getStatistics() {
        this.request({
            url: '/supplier/index/tongji'
        }, res => {
            this.setData({ statistics: res.data })
        })
    },
    /**点击提现按钮 */
    withdrawal() {
        this.setData({ withdrawalLoading: true })
        this.request({
            url: '/supplier/supplier/tixian'
        }, res => {
            this.setData({ withdrawalLoading: false })
            if (Number(res.data.money) <= 0) return wx.showToast({
                title: '余额不足',
                icon: 'none'
            })
            this.setData({
                // openChoose: true,
                enableNum: res.data.money
            })
            wx.navigateTo({
                url: `/pages/withdrawal/index?type=0`,
                success: res => {
                    res.eventChannel.emit('acceptDataFromOpenerPage', { data: this.data.enableNum })
                }
            })
        }, null, () => {
            this.setData({ withdrawalLoading: false })
        })
    },
    // onClickChooseItem(event) { //0---提现至微信  1---提现至银行卡
    //     const { index } = event.detail;
    //     wx.navigateTo({
    //         url: `/pages/withdrawal/index?type=${index}`,
    //         success: res => {
    //             res.eventChannel.emit('acceptDataFromOpenerPage', { data: this.data.enableNum })
    //         }
    //     })
    //     this.setData({ openChoose: false })
    // },
})